<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/media/src/Dropbox/TC/SingleRoundMatch/SRM204/SRMSRM204DIV1_1000.h.html</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#8080ff">//Fri Jul 29 21:37:31 CDT 2011</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;vector&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;list&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;map&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;set&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;deque&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;stack&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;bitset&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;algorithm&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;functional&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;numeric&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;utility&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;sstream&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;iostream&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;iomanip&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;cstdio&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;cmath&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;cstdlib&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;ctime&gt;</font><br>
<br>
<font color="#ffff00">using</font>&nbsp;<font color="#00ff00">namespace</font>&nbsp;std;<br>
<br>
<font color="#00ff00">class</font>&nbsp;WorldPeace {<br>
<font color="#ffff00">public</font>:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;numGroups(<font color="#00ff00">int</font>, vector &lt;<font color="#00ff00">int</font>&gt;);<br>
};<br>
<br>
<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;WorldPeace::numGroups(<font color="#00ff00">int</font>&nbsp;k, vector &lt;<font color="#00ff00">int</font>&gt; c) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;hi = <font color="#ff6060">10000000000000000LL</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;lo = <font color="#ff6060">0LL</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffff00">while</font>(hi &gt; lo){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;mid = (hi + lo + <font color="#ff6060">1</font>) / <font color="#ff6060">2</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00">long</font>&nbsp;<font color="#00ff00">long</font>&nbsp;sum = <font color="#ff6060">0LL</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffff00">for</font>(<font color="#00ff00">int</font>&nbsp;i=<font color="#ff6060">0</font>; i&lt;c.size(); i++){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum += c[i]&lt;mid ? c[i]:mid;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffff00">if</font>(sum &lt; mid * k) hi = mid-<font color="#ff6060">1</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffff00">else</font>&nbsp;lo = mid;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffff00">return</font>&nbsp;hi;<br>
}<br>
<br>
<br>
<font color="#8080ff">//Powered by [KawigiEdit] 2.0!</font><br>
</font></body>
</html>
